﻿using EasyBuyShop.Models;
using EasyBuyShop.Utils;

namespace EasyBuyShop.DAL
{
    public class PurchaseDal : BaseDal
    {
        /// <summary>
        /// 获取当前用户的订单列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List<Purchase> GetPurchases(long userId)
        {
            try
            {
                using (var db = this.GetDb(BaseDal.ConnStr))
                {
                    return db.Queryable<Purchase>().Where(r => r.CustomerId == userId).ToList();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Fatal(ex.Message);
                return new List<Purchase>();
            }
        }
    }
}
